package com.euond.permission.controller;

import com.euond.common.core.dto.ResultDto;
import com.euond.common.web.controller.BaseCRUDController;
import com.euond.permission.entities.Role;
import com.euond.permission.entities.RoleResource;
import com.euond.permission.service.RoleResourceService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created by user on 2017/7/24.
 */
@RestController
@RequestMapping("permission/front/roleresources")
public class RoleResourceController extends BaseCRUDController<RoleResourceService,RoleResource> {

    /**
     * 根据角色查询已分配的资源权限(分页)
     */
    @GetMapping(value = "role/resource")
    public ResultDto findRoleResource(@RequestParam Map<String,Object> searchParams) {
        return baseService.findRoleAvailableResources(searchParams);
    }

    /**
     * 根据角色查询未分配的资源权限
     */
    @GetMapping(value = "role/no/resource")
    public ResultDto findRoleNoResource(@RequestParam Map<String,Object> searchParams) {
        return baseService.findRoleNotAvailableResources(searchParams);
    }

    /**
     * 按条件查询实体列表以分页返回(覆盖基类)
     */
    @GetMapping(value = "page")
    public ResultDto listPage(@RequestParam(required = false) Map<String, Object> map) {
        return baseService.findRoleResources(map);
    }
}
